home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 7684 / 7684.xpi / chrome / firefm.jar / content / fmTrackInfo.xml < prev    next >
Extensible Markup Language  |  2009-09-12  |  13KB  |  350 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4.   - Copyright (c) 2008, Jose Enrique Bolanos, Jorge Villalobos
  5.   - All rights reserved.
  6.   -
  7.   - Redistribution and use in source and binary forms, with or without
  8.   - modification, are permitted provided that the following conditions are met:
  9.   -
  10.   -  * Redistributions of source code must retain the above copyright notice,
  11.   -    this list of conditions and the following disclaimer.
  12.   -  * Redistributions in binary form must reproduce the above copyright notice,
  13.   -    this list of conditions and the following disclaimer in the documentation
  14.   -    and/or other materials provided with the distribution.
  15.   -  * Neither the name of Jose Enrique Bolanos, Jorge Villalobos nor the names
  16.   -    of its contributors may be used to endorse or promote products derived
  17.   -    from this software without specific prior written permission.
  18.   -
  19.   - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20.   - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21.   - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22.   - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  23.   - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24.   - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25.   - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26.   - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27.   - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28.   - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29.   - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.   -->
  31.  
  32. <!DOCTYPE binding [
  33.   <!ENTITY % fmTrackInfoDTD SYSTEM
  34.     "chrome://firefm/locale/fmTrackInfo.dtd" >
  35.   %fmTrackInfoDTD;
  36. ]>
  37.  
  38. <bindings xmlns="http://www.mozilla.org/xbl"
  39.   xmlns:xbl="http://www.mozilla.org/xbl"
  40.   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  41.  
  42.   <!-- Track Info widget -->
  43.   <binding id="firefm-track-info">
  44.     <resources>
  45.       <stylesheet src="chrome://firefm-os/skin/fmTrackInfo.css" />
  46.     </resources>
  47.     <content>
  48.  
  49.       <xul:stringbundleset>
  50.         <xul:stringbundle anonid="stringBundle"
  51.           src="chrome://firefm/locale/fmTrackInfo.properties" />
  52.       </xul:stringbundleset>
  53.  
  54.       <xul:hbox class="firefm-info-outer-box">
  55.         <xul:stack flex="1">
  56.  
  57.           <xul:hbox class="firefm-info-progress-box" flex="1"
  58.             xbl:inherits="progress">
  59.             <xul:hbox
  60.               class="firefm-info-progress-elapsed firefm-info-progress-space" />
  61.             <xul:hbox anonid="elapsed-progress"
  62.               class="firefm-info-progress-elapsed" flex="0" />
  63.             <xul:hbox class="firefm-info-progress-playhead" />
  64.             <xul:hbox anonid="remaining-progress"
  65.               class="firefm-info-progress-remaining" flex="1" />
  66.             <xul:hbox class=
  67.                 "firefm-info-progress-remaining firefm-info-progress-space" />
  68.           </xul:hbox>
  69.  
  70.           <xul:deck anonid="info-deck" class="firefm-info-deck" flex="1"
  71.             selectedIndex="0">
  72.             <xul:hbox flex="1">
  73.               <xul:image anonid="throbber" class="firefm-info-throbber"
  74.                 hidden="true" />
  75.               <xul:label class="firefm-info-message" crop="center"
  76.                 xbl:inherits="value=message" />
  77.             </xul:hbox>
  78.             <xul:hbox flex="1">
  79.               <xul:toolbarbutton type="menu" class="firefm-info-panel-button"
  80.                 tooltiptext="&firefm.trackInfo.dropdown.tooltip;"
  81.                 onclick="_openTrackPanel(this.parentNode)" />
  82.               <xul:label anonid="info-track" class="text-link firefm-track-info"
  83.                 tooltiptext="&firefm.trackInfo.trackTitle.tooltip;" crop="end"
  84.                 xbl:inherits="value=tracktitle,url=trackurl"
  85.                 onclick="_openURL(this, event)" />
  86.               <xul:label value=" - " class="firefm-track-info" />
  87.               <xul:label anonid="info-artist"
  88.                 class="text-link firefm-track-info"
  89.                 tooltiptext="&firefm.trackInfo.artist.tooltip;" crop="start"
  90.                 xbl:inherits="value=artist,url=artisturl"
  91.                 onclick="_openURL(this, event)" />
  92.               <xul:spacer flex="1" />
  93.               <xul:deck anonid="buffering-deck" class="firefm-buffering-deck"
  94.                 selectedIndex="0">
  95.                 <xul:hbox align="center">
  96.                   <xul:spacer flex="1" />
  97.                   <xul:label anonid="info-free"
  98.                     value="&firefm.trackInfo.free.label;"
  99.                     tooltiptext="&firefm.trackInfo.free.tooltip;"
  100.                     class="freeLabel text-link"
  101.                     xbl:inherits="url=freetrackurl"
  102.                     onclick="_openURL(this, event)" />
  103.                   <xul:label class="timeLabel" value="-0:00"
  104.                     xbl:inherits="value=remainingtime" />
  105.                 </xul:hbox>
  106.                 <xul:hbox align="center">
  107.                   <xul:label class="buffering-label"
  108.                     value="&firefm.trackInfo.buffering.label;" />
  109.                 </xul:hbox>
  110.               </xul:deck>
  111.             </xul:hbox>
  112.           </xul:deck>
  113.  
  114.         </xul:stack>
  115.       </xul:hbox>
  116.  
  117.       <xul:panel anonid="trackPanel" >
  118.         <xul:hbox class="firefm-info-panel-outer-box">
  119.           <xul:vbox class="firefm-info-panel-image-box">
  120.             <xul:image xbl:inherits="src=trackimage" />
  121.           </xul:vbox>
  122.           <xul:vbox class="firefm-info-panel-info-box">
  123.             <xul:hbox align="center">
  124.               <xul:label anonid="panel-track"
  125.                 class="text-link firefm-info-panel-track"
  126.                 tooltiptext="&firefm.trackInfo.trackTitle.tooltip;"
  127.                 xbl:inherits="value=tracktitle,url=trackurl"
  128.                 onclick="_openURL(this, event)" />
  129.               <xul:spacer flex="1" />
  130.               <xul:label xbl:inherits="value=remainingtime" />
  131.             </xul:hbox>
  132.             <xul:label anonid="panel-artist"
  133.               class="text-link firefm-info-panel-artist"
  134.               tooltiptext="&firefm.trackInfo.artist.tooltip;"
  135.               xbl:inherits="value=artist,url=artisturl"
  136.               onclick="_openURL(this, event)" />
  137.             <xul:spacer flex="1" />
  138.             <xul:label anonid="panel-album"
  139.               class="text-link firefm-info-panel-album"
  140.               tooltiptext="&firefm.trackInfo.album.tooltip;"
  141.               xbl:inherits="value=album,url=albumurl"
  142.               onclick="_openURL(this, event)" />
  143.             <xul:label anonid="panel-free"
  144.               class="text-link firefm-info-panel-free"
  145.               value="&firefm.trackInfo.free.tooltip;"
  146.               xbl:inherits="url=freetrackurl"
  147.               onclick="_openURL(this, event)" />
  148.             <xul:spacer flex="1" />
  149.           </xul:vbox>
  150.         </xul:hbox>
  151.       </xul:panel>
  152.  
  153.     </content>
  154.  
  155.     <implementation>
  156.       <!-- Logger for this object. -->
  157.       <field name="_logger" />
  158.       <!--  Elements that keep track of elapsed and remaining time. -->
  159.       <field name="_elapsed" />
  160.       <field name="_remaining" />
  161.       <field name="_bufferingDeck" />
  162.  
  163.       <constructor><![CDATA[
  164.         let attributes =
  165.           [ "message", "trackimage", "tracktitle", "trackurl", "artist",
  166.             "artisturl", "albumurl", "albumtitle", "remainingtime", "progress",
  167.             "isbuffering", "freetrackurl" ];
  168.         let attName;
  169.         let attValue;
  170.  
  171.         this._logger = FireFM.getLogger("FireFM.trackinfo");
  172.         this._logger.debug("init");
  173.  
  174.         this._elapsed =
  175.           document.getAnonymousElementByAttribute(
  176.             this, "anonid","elapsed-progress");
  177.         this._remaining =
  178.           document.getAnonymousElementByAttribute(
  179.             this, "anonid","remaining-progress");
  180.         this._bufferingDeck =
  181.           document.getAnonymousElementByAttribute(
  182.             this, "anonid","buffering-deck");
  183.  
  184.         // refresh all attribute values so that the DOMAttrModified event is
  185.         // fired.
  186.         for (let i = 0; i < attributes.length; i++) {
  187.           attName = attributes[i];
  188.           attValue = this.getAttribute(attName);
  189.           this.setAttribute(attName, "");
  190.           this.setAttribute(attName, attValue);
  191.         }
  192.       ]]>
  193.       </constructor>
  194.  
  195.       <method name="_openTrackPanel">
  196.         <parameter name="aButton" />
  197.         <body><![CDATA[
  198.           this._logger.trace("_openTrackPanel");
  199.  
  200.           var panel = document.
  201.             getAnonymousElementByAttribute(this, "anonid", "trackPanel");
  202.           panel.openPopup(aButton, 'after_start');
  203.         ]]>
  204.         </body>
  205.       </method>
  206.  
  207.       <method name="_openURL">
  208.         <parameter name="aSubject" />
  209.         <parameter name="aEvent" />
  210.         <body><![CDATA[
  211.           this._logger.trace("_openURL");
  212.  
  213.           var panel = document.
  214.             getAnonymousElementByAttribute(this, "anonid", "trackPanel");
  215.           panel.hidePopup();
  216.  
  217.           if (1 != aEvent.button) {
  218.             window.openUILink(aSubject.getAttribute('url'), aEvent);
  219.           } else {
  220.             // checkMiddleClick doesn't work for us in this case.
  221.             window.openUILinkIn(aSubject.getAttribute('url'), "tab");
  222.           }
  223.         ]]>
  224.         </body>
  225.       </method>
  226.     </implementation>
  227.     <handlers>
  228.       <handler event="DOMAttrModified"><![CDATA[
  229.         let panelAlbum;
  230.  
  231.         switch (event.attrName) {
  232.           case "message":
  233.             let showMessage = (0 < event.newValue.length)
  234.             let infoDeck =
  235.               document.getAnonymousElementByAttribute(
  236.                 this, "anonid","info-deck");
  237.  
  238.             if (showMessage) {
  239.               infoDeck.selectedIndex = 0;
  240.             } else {
  241.               infoDeck.selectedIndex = 1;
  242.             }
  243.  
  244.             if ("true" == this.getAttribute("small")) {
  245.               document.getAnonymousElementByAttribute(
  246.                 this, "anonid", "throbber").hidden =
  247.                   (!FireFM.Station.isSearchingStation &&
  248.                    !FireFM.Station.isLoadingStation);
  249.             }
  250.             break;
  251.  
  252.           case "tracktitle":
  253.             if (0 < event.newValue.length) {
  254.               document.getAnonymousElementByAttribute(
  255.                 this, "anonid", "info-deck").
  256.                   selectedIndex = 1;
  257.  
  258.               if ("true" == this.getAttribute("small")) {
  259.                 document.getAnonymousElementByAttribute(
  260.                   this, "anonid", "throbber").hidden = true;
  261.               }
  262.             }
  263.             break;
  264.  
  265.           case "trackurl":
  266.             let infoTrack =
  267.               document.getAnonymousElementByAttribute(
  268.                 this, "anonid", "info-track");
  269.             let panelTrack =
  270.               document.getAnonymousElementByAttribute(
  271.                 this, "anonid", "panel-track");
  272.  
  273.             infoTrack.disabled = (0 == event.newValue.length);
  274.             panelTrack.disabled = (0 == event.newValue.length);
  275.             break;
  276.  
  277.           case "freetrackurl":
  278.             let freeLabel =
  279.               document.getAnonymousElementByAttribute(
  280.                 this, "anonid", "info-free");
  281.             let freePanelLabel =
  282.               document.getAnonymousElementByAttribute(
  283.                 this, "anonid", "panel-free");
  284.             if (0 == event.newValue.length) {
  285.               freeLabel.setAttribute("hidden", true);
  286.               freePanelLabel.setAttribute("hidden", true);
  287.             } else {
  288.               freeLabel.removeAttribute("hidden");
  289.               freePanelLabel.removeAttribute("hidden");
  290.             }
  291.             break;
  292.  
  293.           case "artisturl":
  294.             let infoArtist =
  295.               document.getAnonymousElementByAttribute(
  296.                 this, "anonid","info-artist");
  297.             let panelArtist =
  298.               document.getAnonymousElementByAttribute(
  299.                 this, "anonid","panel-artist");
  300.  
  301.             infoArtist.disabled = (0 == event.newValue.length);
  302.             panelArtist.disabled = (0 == event.newValue.length);
  303.             break;
  304.  
  305.           case "albumurl":
  306.             panelAlbum =
  307.               document.getAnonymousElementByAttribute(
  308.                 this, "anonid","panel-album");
  309.             panelAlbum.disabled = (0 == event.newValue.length);
  310.             break;
  311.  
  312.           case "album":
  313.             panelAlbum =
  314.               document.getAnonymousElementByAttribute(
  315.                 this, "anonid","panel-album");
  316.             panelAlbum.hidden = (0 == event.newValue.length);
  317.             break;
  318.  
  319.           case "progress":
  320.             // We use a more finely grained progress rate so that the progress
  321.             // bar moves along smoothly.
  322.             let newValue = event.newValue;
  323.             let progress;
  324.  
  325.             newValue =
  326.               (((null != newValue) && (0 < newValue.length)) ? newValue : "0");
  327.  
  328.             progress = Math.round(parseFloat(newValue) * 300);
  329.             this._elapsed.setAttribute("flex", progress);
  330.             this._remaining.setAttribute("flex", (30000 - progress));
  331.             break;
  332.  
  333.           case "isbuffering":
  334.             this._bufferingDeck.selectedIndex =
  335.               (("true" == event.newValue) ? 1 : 0);
  336.  
  337.             if ("true" == this.getAttribute("small")) {
  338.               document.getAnonymousElementByAttribute(
  339.                 this, "anonid", "throbber").hidden = ("true" != event.newValue);
  340.             }
  341.  
  342.             break;
  343.         }
  344.  
  345.        ]]></handler>
  346.     </handlers>
  347.   </binding>
  348.  
  349. </bindings>
  350.